package top.lushi78778.iot.mqtt.core;

import com.aliyun.teaopenapi.models.Config;

/**
 * @ClassName MqttClient
 * @Description mqtt客户端初始化
 * @Author lushi
 * @Date 2021/7/12 21:04
 */
public class MqttClient {
    /**
     * 使用AK&SK初始化账号Client
     *
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.onsmqtt20200420.Client createClient(String accessKeyId, String accessKeySecret,String endpoint) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = endpoint;
        return new com.aliyun.onsmqtt20200420.Client(config);
    }
}
